 // 推荐机构
import React, {Component} from 'react'
import {
    StyleSheet,
    View,
    Text,
    Image,
    ListView,
    TouchableOpacity,
    FlatList
} from 'react-native'

const Dimensions = require('Dimensions');
const {width,height} = Dimensions.get('window');
import {setSpText} from './ScreenUtil'

// listItem marginLeft

export default class Mechanism extends Component {
    constructor(props){
        super(props);
    }
    
    gogogo(cb) {
        this.refs.test.measure(cb)
    }
    // 机构一期暂时先不做 故用空白页代替
    render() {
        return (
            <View style={styles.commandMechanism} ref="test">
                {/* 空白页 */}
                <View style={styles.empty}>
                    <Image style={{width: 190, height: 150}} source={require('../assets/imgs/noting.png')} />
                    <Text style={{textAlign:'center',height:60,lineHeight:30,fontSize:14}}>敬请期待</Text>
                </View>
                
                {/* <FlatList
                    data={this.props.MechanismList}
                    showsVerticalScrollIndicator={true}
                    renderItem={({ item }) => this.renderMechanismRow(item)}
                    keyExtractor={(item, index) => index}
                /> */}
            </View>
        )
    }
    
    renderMechanismRow(rowData) {
        return (
            <View style={styles.mechanismItem}>
                <Image style={styles.mechanismImg} source={{uri: rowData.PIC}} />
                <View style={styles.mechanismRight}>
                    <Text style={styles.mechanismName}>{rowData.ORG_NAME}</Text>
                    <Text style={styles.address}>地址：{rowData.ADDRESS}</Text>
                    <Text style={styles.tellPhone}>电话：{rowData.PHONE}</Text>
                </View>
            </View>
        )
    }
    // 超出字数省略号
    // MoreText(text,MaxNum){
    //     if(text){
    //         if(text.length>MaxNum){
    //             return(
    //                 text.substring(0,MaxNum)+'...'
    //             )
    //         }else{
    //             return(
    //                 text
    //             )
    //         }
    //     }
    // }
}



const styles = StyleSheet.create({
    // 推荐机构
    commandMechanism: {
        // flex: 1,
        backgroundColor: '#F7F7F9'
    },
    empty:{
        backgroundColor:'#fff',
        flexDirection:'column',
        alignItems: 'center',
        justifyContent: 'center',
        width:width,
        paddingTop: 50,
        paddingBottom: 50,
        // height: height - 66
    },
    mechanismItem: {
        padding: 10,
        flexDirection: 'row',
        marginBottom:5,
        backgroundColor: '#fff'
    },
    mechanismImg: {
        width: 79,
        height: 79,
        marginRight: 10,
        resizeMode: 'cover'
    },
    mechanismRight: {
        width: width - 110,
    },
    mechanismName: {
        fontSize:setSpText(30),
        fontWeight: 'bold',
        marginBottom: 10,
        paddingTop:2,
        color:'#333',
    },
    address: {
        fontSize:setSpText(24),
        color:'#666666',
        marginBottom: 5,
    },
    tellPhone: {
        fontSize:setSpText(24),
        color:'#666666',
    }
})